﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using HNQXYJ.BLL;
using HNQXYJ.Model;
namespace HNQXYJ.DataCenterJS
{
    public partial class TerminalInsertData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void reset_Click(object sender, ImageClickEventArgs e)
        {
            this.txtPhone.Text = "";
            this.txtTownName.Text = "";
            this.txtLeader.Text = "";
            this.txtLeaderPhone.Text = "";
            this.txtStatus.Value = "";
            this.txtLng.Text = "";
            this.txtLat.Text = "";
            this.txtNotes.Text = "";
            
        }

        protected void add_Click(object sender, ImageClickEventArgs e)
        {
            int res = 0;
            Terminal tm = new Terminal();
            tm.Phone = this.txtPhone.Text.Trim();
            tm.TownName = this.txtTownName.Text.Trim();
            tm.AreaCode = "000";//等待分组的应用
            tm.Leader = txtLeader.Text.Trim();
            tm.LeaderPhone = txtLeaderPhone.Text.Trim();
            tm.Statuss = txtStatus.Value;
            tm.Lng = Convert.ToDouble(txtLng.Text.Trim());
            tm.Lat = Convert.ToDouble(txtLat.Text.Trim());
            tm.RankLevel = this.HidCounty.Value;
            tm.Category = txtCatgeory.Value;
            tm.AddDate = DateTime.Now.ToShortDateString();
            tm.Notes = txtNotes.Text.Trim();
            res = TerminalBLL.InsertTerminalData(tm);

            if (res > 0)
            {
                Response.Redirect("../DataCenterJS/TerminalGetAllData.aspx", true);
                //this.Label1.Text = "插入成功";
            }
            else
            {
                this.Label1.Text = "插入失败";
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("../DataCenterJS/TerminalGetAllData.aspx", true);
        }
    }
}